package me.dracen.service

/**
 * Created by liuzinong on 2017/8/15.
 */
class H {

    def static main(args){
        //move(3,'A','B','C')
        //println(yanghui(100))
        println(fibo(40))
        println(fib(40))
    }

    static move (n,a,b,c) {
        if (n == 1) println("move:${a}-->${c}")

        else {
            move(n-1,a,c,b) //从a通过b移到c
            move(1,a,b,c)
            move(n-1,b,a,c)

        }
    }

    static fibo (n) {
        if (n <=2 ) return 1
        else return fibo_tail (n,1,1)
    }
    static fibo_tail (n,int x1,int x2) {
        if (n == 2) return x2
        return fibo_tail(n-1,x2,x1+x2)
    }

    static fib(n) {
        if (n <=2 ) 1
        else fib(n-1) + fib(n-2)
    }



}
